/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.tbl;

import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import org.tnmk.common.util.ImageUtils;

/**
 *
 * @author tnmkhoi
 */
public class ButtonFactory {
  public static void decorateCellButton(JButton button, String label) {
    button.setText(label);
    button.setMargin(new Insets(0, 4, 0, 4));
    button.setFocusPainted(false);
    button.setRolloverEnabled(false);
  }

  public static void decorateCellButtonByType(JButton button, String type) {
//    button.setText(label);
    if (type.equals(ButtonType.EDIT_NORM.toString())) {
      button.setIcon(new ImageIcon(ImageUtils.loadFromClassPath("img/btn/btn_edit_norm.png")));
    }else if (type.equals(ButtonType.EDIT_ACTIVE.toString())) {
      button.setIcon(new ImageIcon(ImageUtils.loadFromClassPath("img/btn/btn_edit_active.png")));
    }else if (type.equals(ButtonType.DELETE.toString())) {
      button.setIcon(new ImageIcon(ImageUtils.loadFromClassPath("img/form/close.png")));
    }else{
      button.setText(type);
    }
    button.setBorder(null);
    button.setBackground(javax.swing.UIManager.getDefaults().getColor("FormattedTextField.background"));
    button.setAlignmentY(0.0F);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setMargin(new java.awt.Insets(0, 0, 0, 0));
    button.setMinimumSize(new java.awt.Dimension(16, 16));
    button.setPreferredSize(new java.awt.Dimension(16, 16));
    button.setRolloverEnabled(false);
  }
}
